/*
 * Copyright (c) 2018. J4dream created
 */

package com.j4dream.property;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class Utils {
    public static void waitActiveThreadFinish() {

        // 默认线程数 main, Monitor Ctrl-Break
//        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
//        int chreaCount = Thread.activeCount();
//        Thread[] threads = new Thread[chreaCount];
//        threadGroup.enumerate(threads);
//        for (int i = 0; i < chreaCount; i++) {
//            log.info("线程号：" + i + " = " + threads[i].getName());
//        }

        while (Thread.activeCount() > 2) {
            try {
                log.info("Current Active Thread: " + Thread.activeCount());
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    // show end log for debug issue.
    public static void endFlag() {
        log.info("Function end.");
    }

    public static void out(String str) {
        System.out.println(String.format("Test case sysout msg: %s", str));
    }
}
